function showEmailWindow() {
	$('.emailForm').fadeIn();
	return false;
}

function hideEmailWindow() {
	$('.emailForm').fadeOut();
	return false;
}


function resizeEmailWindow() {
	var currentHeight = $('.emailForm').height();
	
	var inputCount = $('.emailForm .inputs input.defTxt').length;
	if (inputCount < 5 ) {
		$('.emailForm').height(currentHeight + 50);
		
		
		var input = '<div class="item"><input type="text" name="emailAddr'+inputCount+'" value="enter email address" class="defTxt email" size="50"/></div>';
		$('.inputs').append(input);
		
		activateFormInput();
	}
	return false;
	
}

function activateFormInput()
{
 var ltxt = $('input.email').attr('value');
 
 $('input.email').focusin(
	function(){
		if($(this).val() == ltxt) $(this).val('');
	}
 
 );
 
 
 $('input.email').focusout(
	function(){
		if ($(this).val().length == 0) $(this).val(ltxt);
 });
 
 
}

function showServiceInfo (tr) {
	$(tr).find('p.desc').toggle();
	return false;
}

$(document).ready(	
	function(){
		
		$('.sendEmails').click( function() {
			return showEmailWindow();
			});
		
		$('a.close').click( function() {
			return hideEmailWindow();
			});
		
		$('.addEmail').click( function() {
			return resizeEmailWindow();
			});
		
		$('table.services tr').click( function() {
			showServiceInfo(this);
			});
		
		activateFormInput();
		
		
		var el = $('.focusin');
		var txt = el.attr('rel');
		el.focusin(function() {
			if ($(this).val() == txt) $(this).val("");
		}).focusout(function() {
			if ($(this).val().trim().length == 0) $(this).val(txt);
		}) 
	}
	

);


